package com.example.controller;

import com.example.entity.Orders;
import com.example.service.OrderService;
import com.example.util.ResultCodeUtil;
import com.example.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author : chenjianhua
 * @date : 17:04 2021/2/23
 */

@CrossOrigin
@RestController
public class OrdersController {


    @Autowired
    private OrderService orderService;


    @PostMapping("/qryInfoOrders")
    public ResultUtil qryInfo(){
        List<Orders> ordersList = null;
        try {
            ordersList = orderService.qryOrdersInfo();
            System.out.println("打印一下");
            System.out.println(ordersList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ResultUtil(ResultCodeUtil.SUCCESS,ordersList);
    }

    @PostMapping("/qryInfoOrdersByDay")
    public ResultUtil qryInfoByDay(){
        List<Orders> ordersList = null;
        try {
            ordersList = orderService.qryOrdersInfoByDay();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ResultUtil(ResultCodeUtil.SUCCESS,ordersList);
    }





}
